<!--
- Author:   .
- Date:    2017/7/17 0017.
- File:    password.
-->
<template>
  <div>
    <div class="FormFilling hidden">
      <ul>
        <li class="mb20 ">
          <div class="rightcon w548">
            <input ref="username" class="inp" type="text" placeholder="输入新昵称" v-model="name">
          </div>
        </li>
      </ul>
    </div>
    <div class="pl20 pr20 mt20">
      <button type="button" class="but_1 wauto" @click="updateName">提交</button>
    </div>
    <footer-tab></footer-tab>
  </div>
</template>

<script>
  import {mapModules, mapRules} from 'vuet'

  export default{
    mixins: [
      mapModules({memberInfo: 'memberInfo'}),
      mapRules({once: 'memberInfo'})
    ],
    data() {
      return {
      }
    },
    created() {
      this.name = this.memberInfo.member_name
    },
    computed: {
      name: function () {
        return this.memberInfo.member_name
      }
    },
    methods: {
      updateName() {
        let name = this.$refs.username.value
        if (!name) {
          this.$toast('请输入昵称')
          return
        }
        this.$request.editUserName(name).then(data => {
          this.$toast('提交成功')
          this.memberInfo.member_name = name
          this.$router.go(-1)
        })
      }
    }
  }
</script>

<style>

</style>